/*
 * 
 * @param {Object} name
 */
function checkAll(name) {
    var checkbox = document.getElementsByName(name);
    for (var i=0; i<checkbox.length; i++) {
        checkbox[i].checked=true;
    }
}

function checkNone(name) {
    var checkbox = document.getElementsByName(name);
    for (var i=0; i<checkbox.length; i++) {
        checkbox[i].checked=false;
    }
}

function checkSelection(check,name) {
	if(check.checked) {
		checkAll(name);
	}
	else {
		checkNone(name);
	}
}

function checkSelected(selectname) {
	select=document.getElementById(selectname);
	//Check select
	if(select==null) {
		alert('for debug select');
		return;
	}
	selectOptions=select.options;
	if(selectOptions==null) {
		alert('for debug options');
		return;
	}
	var i=0;

	while(i<selectOptions.length) {
	    var opt=selectOptions[i];
        opt.selected=true;
        i++;
    }
}

function confirmDelete(promt,msg) {
    var answer=confirm(promt);
    if(!answer)
        return false;

	return true;
}

function checkPassword( pwd1, pwd2 )
{
	if( pwd1.value == pwd2.value )
	return true;
	else
		alert("Two passwords don't match!");
	return false;
}

function isCheck( name, objname)
{
 	var checkbox = document.getElementsByName(name);
    for (var i=0; i<checkbox.length; i++) {
       if( checkbox[i].checked == true )
       	return true;
    }
    alert("You have to choose some "+ objname +"  first!");
    return false;
}

function ajaxReady()
{
	var xmlhttp;
	try{
	xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
	}
	catch(e)
	{
		try{
			xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
			}
		catch(e)
		{
			try{ xmlhttp = new XMLHttpRequest();}
			catch(e){}
		}
	}
	return xmlhttp;					
}


function divdisplay(divid,open) {
	var div=document.getElementById(divid);
	if(!div) {
		alert(divid);
	}
	if(open) {
		div.style.display="block";
	}
	else {
		div.style.display="none";
	}
}